package com.example.xiaomaotv;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main2);
        Intent intent = getIntent();
        TextView nameText=findViewById(R.id.list_name_x);
        ImageView animeImg=findViewById(R.id.list_img_x);
        TextView briefText=findViewById(R.id.list_brief_x);
        nameText.setText(intent.getStringExtra("Name"));
        animeImg.setImageResource(intent.getIntExtra("Img",R.drawable.anime_labi));
        briefText.setText(intent.getStringExtra("Brief"));
        Button selectedBtn = findViewById(R.id.list_select);
        selectedBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity2.this);
                builder.setTitle("确认播放")
                        .setMessage("是否确认播放" + nameText.getText().toString() + "?")
                        .setPositiveButton("确认", (dialog, which) -> {
                            Intent intent = new Intent(MainActivity2.this, MainActivity3.class);
                            intent.putExtra("list_name",nameText.getText().toString());
                            startActivity(intent);
                        })
                        .setNegativeButton("取消", (dialog, which) -> {
                            dialog.dismiss();
                        });
                AlertDialog dialog = builder.create();
                dialog.show();
            }
        });
    }
}